require 'open-uri'
require 'hpricot'

class DepartmentAbbreviationsController < ApplicationController
  # GET /department_abbreviations
  # GET /department_abbreviations.xml
  def index
    @department_abbreviations = DepartmentAbbreviation.all

    @department_abbreviation = DepartmentAbbreviation.new

    respond_to do |format|
      format.html # index.html.erb
      format.xml  { render :xml => @department_abbreviations }
    end
  end

  # POST /department_abbreviations
  # POST /department_abbreviations.xml
  def create
    @department_abbreviation = DepartmentAbbreviation.new(params[:department_abbreviation])

    respond_to do |format|
      if @department_abbreviation.save
        flash[:notice] = 'Event was successfully created.'
        format.html { redirect_to(department_abbreviations_url) }
        format.xml  { render :xml => @department_abbreviation, :status => :created, :location => @department_abbreviation }
      else
        format.html { render :action => "new" }
        format.xml  { render :xml => @department_abbreviation.errors, :status => :unprocessable_entity }
      end
    end
  end

  # DELETE /department_abbreviations/1
  # DELETE /department_abbreviations/1.xml
  def destroy
    @department_abbreviation = DepartmentAbbreviation.find(params[:id])
    @department_abbreviation.destroy

    respond_to do |format|
      format.html { redirect_to(department_abbreviations_url) }
      format.xml  { head :ok }
    end
  end

  def fetch_list

    @departments = DepartmentAbbreviation.fetch_and_assign_abbreviations

  end

end
